package com.memo4android.model;


import com.memo4android.ui.TodoButton;
import com.memo4android.ui.TodoClickedListener;
import com.memo4android.ui.TodoLongClickedListener;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class TodoAdapter extends BaseAdapter {
	private Context mContext;
	private ItemTodoList TodoList;
	LayoutInflater inflater;

    public TodoAdapter(Context c, ItemTodoList Tdl) {
    	mContext = c;
        TodoList = Tdl;
    }


	public int getCount() {
		return TodoList.getNumberOfTodos();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return TodoList.getTodos().get(arg0);
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}
	

	public View getView(int position, View convertView, ViewGroup parent) {
		Todo todo = TodoList.getTodo(position);
		TodoButton todoButton = new TodoButton(mContext,todo);
		todoButton.setOnClickListener(new TodoClickedListener(todo));
		todoButton.setOnLongClickListener(new TodoLongClickedListener(mContext, todo, todo.getParent()));
		return todoButton;
	}
}
